
/*
ID: icerupt1
LANG: JAVA
TASK: buylow
*/

/*
 * good.
 * 关键是不重复的计数，考虑 3 2 2 1, 对于两个相同的数字2, 可以从第一个转移的
 * 一定可以从后面转移，所以前面的都是重复状态，只需要累加每种数字最后一次出现
 * 的位置的次数就行。
 * 然后学了一发java，因为还需要高精度。
 *
 */

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class buylow {
	final int inf = 1<<25;
	final int maxn = 5005;
	int[] f = new int[maxn];
	BigInteger[] count = new BigInteger[maxn];
	int da[] = new int[maxn];
	int n;

	public void work(InputReader in, PrintWriter out) {
		n = in.nextInt();
		System.out.println(n);
		for (int i = 1; i <= n; i++) da[i] = in.nextInt();
		for (int i = 0; i < n; i++) System.out.println(da[i]);
		System.out.println("----");

		da[0] = inf; da[++n] = -1; f[0] = 1;
		for (int i = 0; i <= n; i++) count[i] = BigInteger.valueOf(0);
		int max_len = 0;
		for (int i = 1; i <= n; i++) {
			f[i] = 1;
			for (int j = i-1; j >= 0; j--)
				if (da[i] < da[j]) f[i] = Math.max(f[i], f[j]+1);
			max_len = Math.max(max_len, f[i]);
		}

		count[0] = BigInteger.valueOf(1);
		for (int i = 1; i <= n; i++) {
			HashSet<Integer> duplicate = new HashSet<Integer>();
			for (int j = i-1; j >= 0; j--)
				if (da[i] < da[j] && f[i] == f[j] + 1)
					if (!duplicate.contains(Integer.valueOf(da[j]))) {
						count[i] = count[i].add(count[j]);
						duplicate.add(Integer.valueOf(da[j]));
					}
		}

		for (int i = 0; i <= n; i++) System.out.println(da[i]);

		out.print(max_len - 2);
		out.print(" ");
		out.println(count[n]);
		out.close();
	}

	public static void main (String [] args) throws IOException {
		InputReader in = new InputReader(new FileInputStream("buylow.in"));
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("buylow.out")));

		new buylow().work(in, out);
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;

	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream), 32768);
		tokenizer = null;
	}

	public String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public String nextLine() {
		try {
			return reader.readLine();
		} catch (IOException e) {
			throw new IOError(e);
		}
	}
}

